<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
              crossorigin="anonymous">
        <link rel="stylesheet" th:href="@{/css/global.css}"/>
        <title>Title</title>
    </head>
    <body>

        <input type="button" value="发送数据" onclick="post();">
        <p>总数量：<span th:text="${page.rows}"></span></p>
        <p>路径：<span th:text="${page.path}"></span></p>
        <a th:href="@{${page.path}(current=2)}">该变当前页</a>

        <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
                crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
                crossorigin="anonymous"></script>
        <script th:src="@{/js/global.js}"></script>
        <script>
            function post() {
                var map = {};
                map["name"] = "yang";
                map["age"] = 18;
                map["major"] = "计算机科学与技术";
                $.ajax({
                    url: CONTEXT_PATH + "/testMap",
                    type: 'post',
                    contentType: 'application/json;charset=utf-8',
                    dataType: 'json',
                    data: JSON.stringify(map),
                    success: function (data) {
                        console.log(data);
                        console.log(data.name);
                    }
                });
            }
            function testData() {
                $.ajax({
                    url: CONTEXT_PATH + '/testWrite',
                    type: 'post',
                    data: '',
                    dataType: 'json',
                    success:function (data) {
                        alert(data.msg);
                    }
                });

            }
        </script>
    </body>
</html>